import {Box, Button, Static} from '../components'
import {Popconfirm} from 'antd'

const getStopPropagation = (e) => {

    const ev = e || event;
    if (ev.stopPropagation) {
        ev.stopPropagation();
    } else { //IE
        window.event.cancelBubble = true;
    }
}


const JobFairInfo = ({name, title, note, onClick, content, address, time, mobile, contacts, updateTime}: { updateTime: any, name?: string, address?: string, time?: string, mobile?: string, contacts?: string }) => (
    <Box width='100%' height='4rem' padding='0 1rem 0 0' flex='flex' justify='space-between'>
        <Box flex='flex' direction='column' align='flex-start'>
            <Box marginBottom='.5rem'>
                <Static label={name} fontSize='1.1rem' fontWeight='400' marginRight='1rem'/>
                <Static label={'最后更新于 ' + updateTime} color='#9fa3b0'/>
            </Box>

            <Box>
                <Static label='地址：' color='#9fa3b0'/>
                <Static label={address} marginRight='2rem'/>
                <Static label='时间：' color='#9fa3b0'/>
                <Static label={time} marginRight='2rem'/>
                <Static label='联系人：' color='#9fa3b0'/>
                <Static label={contacts} marginRight='2rem'/>
                <Static label='联系电话：' color='#9fa3b0'/>
                <Static label={mobile}/>
            </Box>
        </Box>
        <Box>
            {note
                ? <Popconfirm placement="top"
                              title={content || '没标题'}
                              onConfirm={onClick}
                              okText="确定" cancelText="取消"
                >
                    <Button title={title} type='primary' onClick={getStopPropagation}/>
                </Popconfirm>
                : <Button title={title} type='primary'
                          onClick={e => {
                              getStopPropagation(e);
                              onClick()
                          }}/>
            }
        </Box>
    </Box>
);

const Text = ({content, reactContent, reactTitle}) => (
    <Box width='100%' bgColor='#f7f7f7' flex='flex' justify='space-between' padding='1.5rem' align='flex-start'
         style={{fontSize: '.75rem', lineHeight: '22px'}}>
        <Box width={reactContent ? '50%' : '100%'}
             flex='flex' direction='column' align='flex-start'
        >
            <Static label='招聘会简介' fontSize='1rem' color='#35c0c1' marginBottom='.5rem'/>
            {content}
        </Box>
        {
            reactContent &&
            <Box width='50%' flex='flex' direction='column' align='flex-start'>
                <Static label={reactTitle || '回应信息'} fontSize='1rem' color='#35c0c1' marginBottom='.5rem'/>
                {reactContent}
            </Box>
        }
    </Box>
)

export {Text, JobFairInfo}